#   业务层：实现功能逻辑（注册和登录）
import orm
def login():    #登录
    tag = 0
    name = input('请输入用户名：')
    pwd = input('请输入密码：')
    sql = f"""
            select * from text where NAME='{name}' and PASSWORD='{pwd}'
        """
    data = orm.read_data(sql)
    if data != ():
        tag = 1
        print('登陆成功')
    else:
        print('登陆失败')
    return tag
def register(): #注册
    tag = 0
    name = input('请输入注册用户名：')
    pwd = input('请输入注册密码：')
    sql = f"""
                insert into text values(null,'{name}','{pwd}')
            """
    rows = orm.writer_data(sql)
    if rows > 0:
        tag = 1
        print('注册成功')
    else:
        print('注册失败')
    return tag
if __name__ == '__main__':
    # 测试一下 assert()
    #print(assert())
    # 测试一下 register()
    print(register())

